 package handling.channel.handler;


import client.MapleCharacter;
import client.MapleClient;
import constants.GameConstants;
import constants.ServerConstants;
import handling.channel.ChannelServer;
import handling.opcode.PartyOpcode;
import handling.world.PartyOperation;
import handling.world.World;
import handling.world.WorldFindService;
import handling.world.WorldPartyService;
import handling.world.party.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import server.quest.MapleQuest;
import tools.MaplePacketCreator;
import tools.StringUtil;
import tools.data.input.LittleEndianAccessor;
import tools.packet.PartyPacket;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
























 public class PartyHandler {
/*  27 */   private static final Logger log = LogManager.getLogger();



   public static void DenyPartyRequest(LittleEndianAccessor slea, MapleClient c) {
     MapleCharacter cfrom;
     MapleParty toParty;
/*  34 */     short action = (short)slea.readByte();
/*  35 */     int fromId = slea.readInt();
/*  36 */     PartyOpcode opcode = PartyOpcode.Companion.getByAction(action);
/*  37 */     if (opcode == null) {
/*  38 */       log.error("第二方收到组队邀请处理( 0x" + StringUtil.getLeftPaddedStr(Integer.toHexString(action).toUpperCase(), '0', 2) + " ) 未知.");

       return;
     }
/*  42 */     WorldPartyService partyService = WorldPartyService.getInstance();
/*  43 */     switch (opcode) {
       case PartyRes_InviteParty_Rejected:
/*  45 */         cfrom = c.getChannelServer().getPlayerStorage().getCharacterById(fromId);
/*  46 */         if (cfrom != null) {
/*  47 */           cfrom.dropMessage(5, "'" + c.getPlayer().getName() + "'玩家拒绝了组队招待。");
         }
         return;
       case PartyRes_InviteParty_Accepted:
/*  51 */         if (c.getPlayer().getParty() != null) {
/*  52 */           c.getPlayer().dropMessage(5, "您已经有一个组队，无法加入其他组队!");
           return;
         }
/*  55 */         toParty = partyService.getPartyByLeaderId(fromId);
/*  56 */         if (toParty == null) {
/*  57 */           c.getPlayer().dropMessage(5, "要参加的队伍不存在。");
           return;
         }
/*  60 */         if (toParty.getExpeditionId() > 0) {
/*  61 */           c.getPlayer().dropMessage(5, "要加入的队伍为远征小队，无法进行此操作。");
           return;
         }
/*  64 */         if (toParty.getMembers().size() < 6) {
/*  65 */           c.getPlayer().setParty(toParty);
/*  66 */           partyService.updateParty(toParty.getPartyId(), PartyOperation.加入队伍, new MaplePartyCharacter(c.getPlayer()));
/*  67 */           c.getPlayer().receivePartyMemberHP();
/*  68 */           c.getPlayer().updatePartyMemberHP();
         } else {
/*  70 */           c.getPlayer().dropMessage(5, "组队成员已满");
         }
         return;
     }
/*  74 */     log.error("第二方收到组队邀请处理( 0x" + StringUtil.getLeftPaddedStr(Integer.toHexString(action).toUpperCase(), '0', 2) + " ) 未知.");
   }







































































   public static void PartyOperation(LittleEndianAccessor slea, MapleClient c) {
     boolean isHidden;
     String partyName;
     int partyid;
     String theName;
     int theCh, toPartyId;
/* 153 */     byte code = slea.readByte();
/* 154 */     PartyOpcode operation = PartyOpcode.Companion.getByAction((short)code);
/* 155 */     if (operation == null) {
/* 156 */       System.out.println("组队邀请处理( " + code + " ) 未知.");
       return;
     }
/* 159 */     MapleParty party = c.getPlayer().getParty();
/* 160 */     WorldPartyService partyService = WorldPartyService.getInstance();
/* 161 */     MaplePartyCharacter partyPlayer = new MaplePartyCharacter(c.getPlayer());
/* 162 */     switch (operation) {
       case PartyReq_CreateNewParty:
/* 164 */         isHidden = (slea.readByte() == 0);
/* 165 */         partyName = slea.readMapleAsciiString();
/* 166 */         if (party == null) {
/* 167 */           party = partyService.createParty(partyPlayer, partyName, isHidden);
/* 168 */           c.getPlayer().setParty(party);
/* 169 */           c.announce(PartyPacket.partyCreated(party));
         } else {
/* 171 */           if (party.getExpeditionId() > 0) {
/* 172 */             c.getPlayer().dropMessage(5, "加入远征队伍的状态下无法进行此操作。");
             return;
           }
/* 175 */           if (partyPlayer.equals(party.getLeader()) && party.getMembers().size() == 1) {
/* 176 */             c.announce(PartyPacket.partyCreated(party));
           } else {
/* 178 */             c.getPlayer().dropMessage(5, "你已经存在一个队伍中，无法创建！");
           }
         }
         return;
       case PartyReq_WithdrawParty:
/* 183 */         if (party != null) {
/* 184 */           if (party.getExpeditionId() > 0) {
/* 185 */             c.getPlayer().dropMessage(5, "加入远征队伍的状态下无法进行此操作。");
             return;
           }
/* 188 */           if (partyPlayer.equals(party.getLeader())) {
/* 189 */             if (c.getPlayer().getPyramidSubway() != null) {
/* 190 */               c.getPlayer().getPyramidSubway().fail(c.getPlayer());
             }
/* 192 */             partyService.updateParty(party.getPartyId(), PartyOperation.解散队伍, partyPlayer);
/* 193 */             if (c.getPlayer().getEventInstance() != null) {
/* 194 */               c.getPlayer().getEventInstance().disbandParty();
             }
           } else {
/* 197 */             if (c.getPlayer().getPyramidSubway() != null) {
/* 198 */               c.getPlayer().getPyramidSubway().fail(c.getPlayer());
             }
/* 200 */             partyService.updateParty(party.getPartyId(), PartyOperation.离开队伍, partyPlayer);
/* 201 */             if (c.getPlayer().getEventInstance() != null) {
/* 202 */               c.getPlayer().getEventInstance().leftParty(c.getPlayer());
             }
           }
/* 205 */           c.getPlayer().setParty(null);
         }
         return;
       case PartyReq_JoinParty:
/* 209 */         partyid = slea.readInt();
/* 210 */         if (party != null) {
/* 211 */           c.getPlayer().dropMessage(5, "您已经有一个组队，无法加入其他组队!");
           return;
         }
/* 214 */         party = partyService.getParty(partyid);
/* 215 */         if (party != null) {
/* 216 */           if (party.getExpeditionId() > 0) {
/* 217 */             c.getPlayer().dropMessage(5, "加入远征队伍的状态下无法进行此操作。");
             return;
           }
/* 220 */           if (party.getMembers().size() < 6) {
/* 221 */             c.getPlayer().setParty(party);
/* 222 */             partyService.updateParty(party.getPartyId(), PartyOperation.加入队伍, partyPlayer);
/* 223 */             c.getPlayer().receivePartyMemberHP();
/* 224 */             c.getPlayer().updatePartyMemberHP();
           } else {
/* 226 */             c.getPlayer().dropMessage(5, "组队成员已满");
           }
         } else {
/* 229 */           c.getPlayer().dropMessage(5, "要加入的队伍不存在");
         }
         return;
       case PartyReq_InviteParty:
/* 233 */         if (party == null) {
/* 234 */           party = partyService.createParty(partyPlayer);
/* 235 */           c.getPlayer().setParty(party);
/* 236 */           c.announce(PartyPacket.partyCreated(party));
         }
/* 238 */         theName = slea.readMapleAsciiString();
/* 239 */         theCh = WorldFindService.getInstance().findChannel(theName);
/* 240 */         if (theCh > 0) {
/* 241 */           MapleCharacter invited = ChannelServer.getInstance(theCh).getPlayerStorage().getCharacterByName(theName);
/* 242 */           if (invited != null) {
/* 243 */             if (party.getExpeditionId() > 0) {
/* 244 */               c.getPlayer().dropMessage(5, "加入远征队伍的状态下无法进行此操作。");
/* 245 */             } else if (invited.getParty() != null) {
/* 246 */               c.getPlayer().dropMessage(5, "'" + theName + "'已经加入其他组。");
/* 247 */             } else if (invited.getQuestNoAdd(MapleQuest.getInstance(122901)) != null) {
/* 248 */               c.getPlayer().dropMessage(5, "'" + theName + "'玩家处于拒绝组队状态。");
/* 249 */             } else if (party.getMembers().size() < 6) {
/* 250 */               c.announce(PartyPacket.partyStatusMessage(PartyOpcode.PartyRes_InviteParty_Sent.getValue(), invited.getName()));
/* 251 */               invited.getClient().announce(PartyPacket.partyInvite(c.getPlayer()));
             } else {
/* 253 */               c.getPlayer().dropMessage(5, "组队成员已满");
             }
           } else {
/* 256 */             c.getPlayer().dropMessage(5, "在当前服务器找不到..'" + theName + "'。");
           }
         } else {
/* 259 */           c.getPlayer().dropMessage(5, "在当前服务器找不到..'" + theName + "'。");
         }
         return;
       case PartyReq_KickParty:
/* 263 */         if (party != null && partyPlayer != null && partyPlayer.equals(party.getLeader())) {
/* 264 */           if (party.getExpeditionId() > 0) {
/* 265 */             c.getPlayer().dropMessage(5, "加入远征队伍的状态下无法进行此操作。");
             return;
           }
/* 268 */           MaplePartyCharacter expelled = party.getMemberById(slea.readInt());
/* 269 */           if (expelled != null) {
/* 270 */             if (c.getPlayer().getPyramidSubway() != null && expelled.isOnline()) {
/* 271 */               c.getPlayer().getPyramidSubway().fail(c.getPlayer());
             }
/* 273 */             partyService.updateParty(party.getPartyId(), PartyOperation.驱逐成员, expelled);
/* 274 */             if (c.getPlayer().getEventInstance() != null && 
/* 275 */               expelled.isOnline()) {
/* 276 */               c.getPlayer().getEventInstance().disbandParty();
             }
           }
         }
         return;

       case PartyReq_ChangePartyBoss:
/* 283 */         if (party != null) {
/* 284 */           if (party.getExpeditionId() > 0) {
/* 285 */             c.getPlayer().dropMessage(5, "加入远征队伍的状态下无法进行此操作。");
             return;
           }
/* 288 */           MaplePartyCharacter newleader = party.getMemberById(slea.readInt());
/* 289 */           if (newleader != null && partyPlayer.equals(party.getLeader())) {
/* 290 */             partyService.updateParty(party.getPartyId(), PartyOperation.改变队长, newleader);
           }
         }
         return;

       case PartyReq_ApplyParty:
/* 296 */         if (party != null) {
/* 297 */           if (c.getPlayer().getEventInstance() != null || c.getPlayer().getPyramidSubway() != null || party.getExpeditionId() > 0 || GameConstants.isDojo(c.getPlayer().getMapId())) {
/* 298 */             c.getPlayer().dropMessage(5, "加入远征队伍的状态下无法进行此操作。");
             return;
           }
/* 301 */           if (partyPlayer.equals(party.getLeader())) {
/* 302 */             partyService.updateParty(party.getPartyId(), PartyOperation.解散队伍, partyPlayer);
           } else {
/* 304 */             partyService.updateParty(party.getPartyId(), PartyOperation.离开队伍, partyPlayer);
           }
/* 306 */           c.getPlayer().setParty(null);
         }

/* 309 */         party = c.getPlayer().getParty();
/* 310 */         if (party != null) {
/* 311 */           c.getPlayer().dropMessage(5, "无法退出或解散以前的队伍，请手动退出队伍后在进行操作。");

           return;
         }
/* 315 */         toPartyId = slea.readInt();
/* 316 */         party = partyService.getParty(toPartyId);
/* 317 */         if (party != null && party.getMembers().size() < 6) {
/* 318 */           if (party.getExpeditionId() > 0) {
/* 319 */             c.getPlayer().dropMessage(5, "该队伍为远征小队，无法进行此操作加入队伍中。");
             return;
           }
/* 322 */           MapleCharacter cfrom = c.getPlayer().getMap().getCharacterById(party.getLeader().getId());
/* 323 */           if (cfrom != null) {
/* 324 */             c.announce(PartyPacket.partyStatusMessage(66, cfrom.getName()));
/* 325 */             cfrom.getClient().announce(PartyPacket.partyRequestInvite(c.getPlayer()));
           } else {
/* 327 */             c.getPlayer().dropMessage(5, "没有在该地图找此队伍的队长.");
           }
         } else {
/* 330 */           c.getPlayer().dropMessage(5, "要加入的队伍不存在或者人数已满");
         }
         return;
       case PartyReq_SetAppliable:
/* 334 */         if (slea.readByte() > 0) {
/* 335 */           c.getPlayer().getQuestRemove(MapleQuest.getInstance(122900));
         } else {

/* 338 */           c.getPlayer().getQuestNAdd(MapleQuest.getInstance(122900));
         }  return;
       case PartyReq_PartySetting:
/* 341 */         isHidden = (slea.readByte() == 0);
/* 342 */         partyName = slea.readMapleAsciiString();
/* 343 */         if (party != null) {
/* 344 */           partyService.updatePartySetup(party.getPartyId(), PartyOperation.队伍设置, partyName, isHidden);
         }
         return;
     }
/* 348 */     if (ServerConstants.isShowPacket()) {
/* 349 */       System.out.println("组队邀请处理( " + code + " ) 未知.");
     }
   }



   public static void AllowPartyInvite(LittleEndianAccessor slea, MapleClient c) {
/* 356 */     if (slea.readByte() > 0) {
/* 357 */       c.getPlayer().getQuestRemove(MapleQuest.getInstance(122901));
     } else {
/* 359 */       c.getPlayer().getQuestNAdd(MapleQuest.getInstance(122901));
     }
/* 361 */     c.announce(MaplePacketCreator.enableActions());
   }





   public static void MemberSearch(LittleEndianAccessor slea, MapleClient c) {
/* 369 */     if (c != null && c.getPlayer() != null) {
/* 370 */       if (c.getPlayer().isInBlockedMap()) {
/* 371 */         c.getPlayer().dropMessage(5, "无法在这个地方进行搜索.");
/* 372 */         c.announce(MaplePacketCreator.enableActions());
         return;
       }
/* 375 */       List<MapleCharacter> members = new ArrayList<>();
/* 376 */       for (MapleCharacter findchr : c.getPlayer().getMap().getCharactersThreadsafe()) {
/* 377 */         if (findchr != null && findchr.getId() != c.getPlayer().getId() && !members.contains(c.getPlayer()) && !findchr.isHidden() && findchr.getParty() == null) {
/* 378 */           members.add(findchr);
         }
       }
/* 381 */       c.announce(PartyPacket.showMemberSearch(members));
     }
   }




   public static void PartySearch(LittleEndianAccessor slea, MapleClient c) {
/* 389 */     if (c.getPlayer().isInBlockedMap()) {
/* 390 */       c.getPlayer().dropMessage(5, "无法在这个地方进行搜索.");
/* 391 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/* 394 */     MapleParty party = c.getPlayer().getParty();
/* 395 */     List<MapleParty> parties = new ArrayList<>();
/* 396 */     for (MapleCharacter findchr : c.getPlayer().getMap().getCharactersThreadsafe()) {
/* 397 */       if (findchr.getParty() == null || findchr.isHidden() || findchr.getParty().isHidden() || (
/* 398 */         party != null && findchr.getParty().getPartyId() == party.getPartyId())) {
         continue;
       }
/* 401 */       if (!parties.contains(findchr.getParty())) {
/* 402 */         parties.add(findchr.getParty());
       }
     }

/* 406 */     c.announce(PartyPacket.showPartySearch(parties)); } public static void PartyListing(LittleEndianAccessor slea, MapleClient c) { PartySearchType pst;
     MapleParty party;
     int typeId;
     MaplePartyCharacter partyPlayer;
/* 410 */     int mode = slea.readByte();
/* 411 */     WorldPartyService partyService = WorldPartyService.getInstance();



/* 415 */     switch (mode) {
       case 121:
         return;
       case 114:
/* 419 */         typeId = slea.readInt();
/* 420 */         pst = PartySearchType.getById(typeId);
/* 421 */         if (pst == null || c.getPlayer().getLevel() > pst.maxLevel || c.getPlayer().getLevel() < pst.minLevel) {
/* 422 */           System.out.println("创建远征队信息不符合条件 - 类型: " + ((pst == null) ? 1 : 0) + " ID: " + typeId);
           return;
         }
/* 425 */         if (c.getPlayer().getParty() == null && partyService.searchParty(pst).size() < 10) {
/* 426 */           MapleParty mapleParty = partyService.createParty(new MaplePartyCharacter(c.getPlayer()), pst.id);
/* 427 */           c.getPlayer().setParty(mapleParty);
/* 428 */           c.announce(PartyPacket.partyCreated(mapleParty));
/* 429 */           PartySearch ps = new PartySearch(slea.readMapleAsciiString(), pst.exped ? mapleParty.getExpeditionId() : mapleParty.getPartyId(), pst);
/* 430 */           partyService.addSearch(ps);
/* 431 */           if (pst.exped) {
/* 432 */             c.announce(PartyPacket.expeditionStatus(partyService.getExped(mapleParty.getExpeditionId()), true));
           }
/* 434 */           c.announce(PartyPacket.partyListingAdded(ps));
         } else {
/* 436 */           c.getPlayer().dropMessage(1, "您已经有个1个队伍了，请离开队伍后在进行尝试。");
         }

       case 115:
/* 440 */         party = c.getPlayer().getParty();
/* 441 */         if (party != null) {
/* 442 */           PartySearch toRemove = partyService.getSearchByParty(party.getPartyId());
/* 443 */           if (toRemove != null) {
/* 444 */             partyService.removeSearch(toRemove, "组队广告已被删除。");
           } else {
/* 446 */             System.out.println("取消添加远征广告信息 - 广告信息为空");
           }
         } else {
/* 449 */           System.out.println("取消添加远征广告信息 - 是否有队伍: " + ((party != null) ? 1 : 0));
         }

       case 116:
/* 453 */         typeId = slea.readInt();
/* 454 */         pst = PartySearchType.getById(typeId);
/* 455 */         if (pst == null || c.getPlayer().getLevel() > pst.maxLevel || c.getPlayer().getLevel() < pst.minLevel) {
/* 456 */           System.out.println("显示远征队信息不符合条件 - 类型是否为空: " + ((pst == null) ? 1 : 0) + " ID: " + typeId);
           return;
         }
/* 459 */         c.announce(PartyPacket.getPartyListing(pst));

       case 117:
         return;
       case 118:
/* 464 */         party = c.getPlayer().getParty();
/* 465 */         partyPlayer = new MaplePartyCharacter(c.getPlayer());
/* 466 */         if (party == null) {
/* 467 */           int theId = slea.readInt();
/* 468 */           party = partyService.getParty(theId);
/* 469 */           if (party != null) {
/* 470 */             PartySearch ps = partyService.getSearchByParty(party.getPartyId());
/* 471 */             if (ps != null && c.getPlayer().getLevel() <= (ps.getType()).maxLevel && c.getPlayer().getLevel() >= (ps.getType()).minLevel && party.getMembers().size() < 6) {
/* 472 */               c.getPlayer().setParty(party);
/* 473 */               partyService.updateParty(party.getPartyId(), PartyOperation.加入队伍, partyPlayer);
/* 474 */               c.getPlayer().receivePartyMemberHP();
/* 475 */               c.getPlayer().updatePartyMemberHP();
             } else {
/* 477 */               c.announce(PartyPacket.partyStatusMessage(17));
             }
           } else {
/* 480 */             MapleExpedition exped = partyService.getExped(theId);
/* 481 */             if (exped != null) {
/* 482 */               PartySearch ps = partyService.getSearchByExped(exped.getId());
/* 483 */               if (ps != null && c.getPlayer().getLevel() <= (ps.getType()).maxLevel && c.getPlayer().getLevel() >= (ps.getType()).minLevel && exped.getAllMembers() < (exped.getType()).maxMembers) {
/* 484 */                 int partyId = exped.getFreeParty();
/* 485 */                 if (partyId < 0) {
/* 486 */                   c.announce(PartyPacket.partyStatusMessage(17));
/* 487 */                 } else if (partyId == 0) {
/* 488 */                   party = partyService.createPartyAndAdd(partyPlayer, exped.getId());
/* 489 */                   c.getPlayer().setParty(party);
/* 490 */                   c.announce(PartyPacket.partyCreated(party));
/* 491 */                   c.announce(PartyPacket.expeditionStatus(exped, true));
/* 492 */                   partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionJoined(c.getPlayer().getName()), null);
/* 493 */                   partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionUpdate(exped.getIndex(party.getPartyId()), party), null);
                 } else {
/* 495 */                   c.getPlayer().setParty(partyService.getParty(partyId));
/* 496 */                   partyService.updateParty(partyId, PartyOperation.加入队伍, partyPlayer);
/* 497 */                   c.getPlayer().receivePartyMemberHP();
/* 498 */                   c.getPlayer().updatePartyMemberHP();
/* 499 */                   c.announce(PartyPacket.expeditionStatus(exped, true));
/* 500 */                   partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionJoined(c.getPlayer().getName()), null);
                 }
               } else {
/* 503 */                 c.announce(PartyPacket.expeditionInviteMessage(0, c.getPlayer().getName()));
               }
             }
           }
         } else {
/* 508 */           c.getPlayer().dropMessage(1, "您已经有队伍，请退出队伍后在试.");
         }
     }

/* 512 */     if (ServerConstants.isShowPacket()) {
/* 513 */       System.out.println("Unknown PartyListing : 0x" + StringUtil.getLeftPaddedStr(Integer.toHexString(mode).toUpperCase(), '0', 2) + " " + slea);
     } }


   public static void Expedition(LittleEndianAccessor slea, MapleClient c) {
     MapleParty part;
     String name;
     int partySearchId;
     ExpeditionType et;
     int theCh, action, theChh;
/* 523 */     MapleCharacter player = c.getPlayer();
/* 524 */     if (player == null || player.getMap() == null) {
       return;
     }
/* 527 */     int mode = slea.readByte();
/* 528 */     WorldPartyService partyService = WorldPartyService.getInstance();



/* 532 */     switch (mode) {
       case 78:
/* 534 */         partySearchId = slea.readInt();
/* 535 */         et = ExpeditionType.getById(partySearchId);
/* 536 */         if (et != null && player.getParty() == null && player.getLevel() <= et.maxLevel && player.getLevel() >= et.minLevel) {
/* 537 */           MapleParty party = partyService.createParty(new MaplePartyCharacter(player), et.exped);
/* 538 */           player.setParty(party);
/* 539 */           c.announce(PartyPacket.partyCreated(party));
/* 540 */           c.announce(PartyPacket.expeditionStatus(partyService.getExped(party.getExpeditionId()), true));
         } else {
/* 542 */           c.announce(PartyPacket.expeditionInviteMessage(0, "远征模式ID[" + partySearchId + "]"));
         }
         return;
       case 79:
/* 546 */         name = slea.readMapleAsciiString();
/* 547 */         theCh = WorldFindService.getInstance().findChannel(name);
/* 548 */         if (theCh > 0) {
/* 549 */           MapleCharacter invited = ChannelServer.getInstance(theCh).getPlayerStorage().getCharacterByName(name);
/* 550 */           MapleParty party = c.getPlayer().getParty();
/* 551 */           if (invited != null && invited.getParty() == null && party != null && party.getExpeditionId() > 0) {
/* 552 */             MapleExpedition me = partyService.getExped(party.getExpeditionId());
/* 553 */             if (me != null && me.getAllMembers() < (me.getType()).maxMembers && invited.getLevel() <= (me.getType()).maxLevel && invited.getLevel() >= (me.getType()).minLevel) {
/* 554 */               c.announce(PartyPacket.expeditionInviteMessage(7, invited.getName()));
/* 555 */               invited.getClient().announce(PartyPacket.expeditionInvite(player, (me.getType()).exped));
             } else {
/* 557 */               c.announce(PartyPacket.expeditionInviteMessage(3, invited.getName()));
             }
           } else {
/* 560 */             c.announce(PartyPacket.expeditionInviteMessage(2, name));
           }
         } else {
/* 563 */           c.announce(PartyPacket.expeditionInviteMessage(0, name));
         }
         return;
       case 80:
/* 567 */         name = slea.readMapleAsciiString();
/* 568 */         slea.readInt();
/* 569 */         action = slea.readInt();
/* 570 */         theChh = WorldFindService.getInstance().findChannel(name);
/* 571 */         if (theChh > 0) {
/* 572 */           MapleCharacter cfrom = ChannelServer.getInstance(theChh).getPlayerStorage().getCharacterByName(name);
/* 573 */           if (cfrom != null && cfrom.getParty() != null && cfrom.getParty().getExpeditionId() > 0) {
/* 574 */             MapleParty party = cfrom.getParty();
/* 575 */             MapleExpedition exped = partyService.getExped(party.getExpeditionId());
/* 576 */             if (exped != null && action == 8) {
/* 577 */               if (player.getLevel() <= (exped.getType()).maxLevel && player.getLevel() >= (exped.getType()).minLevel && exped.getAllMembers() < (exped.getType()).maxMembers) {
/* 578 */                 int partyId = exped.getFreeParty();
/* 579 */                 if (partyId < 0) {
/* 580 */                   c.announce(PartyPacket.partyStatusMessage(17));
/* 581 */                 } else if (partyId == 0) {
/* 582 */                   party = partyService.createPartyAndAdd(new MaplePartyCharacter(player), exped.getId());
/* 583 */                   player.setParty(party);
/* 584 */                   c.announce(PartyPacket.partyCreated(party));
/* 585 */                   c.announce(PartyPacket.expeditionStatus(exped, true));
/* 586 */                   partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionJoined(player.getName()), null);
/* 587 */                   partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionUpdate(exped.getIndex(party.getPartyId()), party), null);
                 } else {
/* 589 */                   player.setParty(partyService.getParty(partyId));
/* 590 */                   partyService.updateParty(partyId, PartyOperation.加入队伍, new MaplePartyCharacter(player));
/* 591 */                   player.receivePartyMemberHP();
/* 592 */                   player.updatePartyMemberHP();
/* 593 */                   partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionJoined(player.getName()), null);
/* 594 */                   c.announce(PartyPacket.expeditionStatus(exped, false));
                 }
               } else {
/* 597 */                 c.announce(PartyPacket.expeditionInviteMessage(3, cfrom.getName()));
               }
/* 599 */             } else if (action == 9) {
/* 600 */               cfrom.dropMessage(5, "'" + player.getName() + "'拒绝了远征队邀请。");
             }
           }
         }
         return;
       case 81:
/* 606 */         part = player.getParty();
/* 607 */         if (part != null && part.getExpeditionId() > 0) {
/* 608 */           MapleExpedition exped = partyService.getExped(part.getExpeditionId());
/* 609 */           if (exped != null) {
/* 610 */             if (exped.getLeader() == player.getId()) {
/* 611 */               partyService.disbandExped(exped.getId());
/* 612 */               if (player.getEventInstance() != null) {
/* 613 */                 player.getEventInstance().disbandParty();
               }
/* 615 */             } else if (part.getLeader().getId() == player.getId()) {
/* 616 */               partyService.updateParty(part.getPartyId(), PartyOperation.解散队伍, new MaplePartyCharacter(player));
/* 617 */               if (player.getEventInstance() != null) {
/* 618 */                 player.getEventInstance().disbandParty();
               }
             }
             else {

/* 623 */               partyService.updateParty(part.getPartyId(), PartyOperation.离开队伍, new MaplePartyCharacter(player));
/* 624 */               if (player.getEventInstance() != null) {
/* 625 */                 player.getEventInstance().leftParty(player);
               }

/* 628 */               partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionLeft(true, player.getName()), null);
             }
/* 630 */             if (player.getPyramidSubway() != null) {
/* 631 */               player.getPyramidSubway().fail(c.getPlayer());
             }
/* 633 */             player.setParty(null);
           }
         }
         return;
       case 82:
/* 638 */         part = player.getParty();
/* 639 */         if (part != null && part.getExpeditionId() > 0) {
/* 640 */           MapleExpedition exped = partyService.getExped(part.getExpeditionId());
/* 641 */           if (exped != null && exped.getLeader() == player.getId()) {
/* 642 */             int cid = slea.readInt();
/* 643 */             for (Iterator<Integer> iterator = exped.getParties().iterator(); iterator.hasNext(); ) { int i = ((Integer)iterator.next()).intValue();
/* 644 */               MapleParty par = partyService.getParty(i);
/* 645 */               if (par != null) {
/* 646 */                 MaplePartyCharacter expelled = par.getMemberById(cid);
/* 647 */                 if (expelled != null) {
/* 648 */                   partyService.updateParty(i, PartyOperation.驱逐成员, expelled);
/* 649 */                   if (player.getEventInstance() != null && 
/* 650 */                     expelled.isOnline()) {
/* 651 */                     player.getEventInstance().disbandParty();
                   }

/* 654 */                   if (player.getPyramidSubway() != null && expelled.isOnline()) {
/* 655 */                     player.getPyramidSubway().fail(player);
                   }
/* 657 */                   partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionLeft(false, expelled.getName()), null);
                   break;
                 }
               }  }

           }
         }
         return;
       case 83:
/* 666 */         part = player.getParty();
/* 667 */         if (part != null && part.getExpeditionId() > 0) {
/* 668 */           MapleExpedition exped = partyService.getExped(part.getExpeditionId());
/* 669 */           if (exped != null && exped.getLeader() == player.getId()) {
/* 670 */             MaplePartyCharacter newleader = part.getMemberById(slea.readInt());
/* 671 */             if (newleader != null) {
/* 672 */               partyService.updateParty(part.getPartyId(), PartyOperation.改变队长, newleader);
/* 673 */               exped.setLeader(newleader.getId());
/* 674 */               partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionLeaderChanged(0), null);
             }
           }
         }
         return;
       case 84:
/* 680 */         part = player.getParty();
/* 681 */         if (part != null && part.getExpeditionId() > 0) {
/* 682 */           MapleExpedition exped = partyService.getExped(part.getExpeditionId());
/* 683 */           if (exped != null && exped.getLeader() == player.getId()) {
/* 684 */             int cid = slea.readInt();
/* 685 */             for (Iterator<Integer> iterator = exped.getParties().iterator(); iterator.hasNext(); ) { int i = ((Integer)iterator.next()).intValue();
/* 686 */               MapleParty par = partyService.getParty(i);
/* 687 */               if (par != null) {
/* 688 */                 MaplePartyCharacter newleader = par.getMemberById(cid);
/* 689 */                 if (newleader != null && par.getPartyId() != part.getPartyId()) {
/* 690 */                   partyService.updateParty(par.getPartyId(), PartyOperation.改变队长, newleader);
                 }
               }  }

           }
         }
         return;
       case 85:
/* 698 */         part = player.getParty();
/* 699 */         if (part != null && part.getExpeditionId() > 0) {
/* 700 */           MapleExpedition exped = partyService.getExped(part.getExpeditionId());
/* 701 */           if (exped != null && exped.getLeader() == player.getId()) {
/* 702 */             int partyIndexTo = slea.readInt();
/* 703 */             if (partyIndexTo < (exped.getType()).maxParty && partyIndexTo <= exped.getParties().size()) {
/* 704 */               int cid = slea.readInt();
/* 705 */               for (Iterator<Integer> iterator = exped.getParties().iterator(); iterator.hasNext(); ) { int i = ((Integer)iterator.next()).intValue();
/* 706 */                 MapleParty par = partyService.getParty(i);
/* 707 */                 if (par != null) {
/* 708 */                   MaplePartyCharacter expelled = par.getMemberById(cid);
/* 709 */                   if (expelled != null && expelled.isOnline()) {
/* 710 */                     MapleCharacter chr = World.getStorage(expelled.getChannel()).getCharacterById(expelled.getId());
/* 711 */                     if (chr == null) {
                       break;
                     }
/* 714 */                     if (partyIndexTo < exped.getParties().size()) {
/* 715 */                       MapleParty party = partyService.getParty(((Integer)exped.getParties().get(partyIndexTo)).intValue());
/* 716 */                       if (party == null || party.getMembers().size() >= 6) {
/* 717 */                         player.dropMessage(5, "Invalid party.");
                         break;
                       }
                     }
/* 721 */                     partyService.updateParty(i, PartyOperation.驱逐成员, expelled);
/* 722 */                     if (partyIndexTo < exped.getParties().size()) {
/* 723 */                       MapleParty party = partyService.getParty(((Integer)exped.getParties().get(partyIndexTo)).intValue());
/* 724 */                       if (party != null && party.getMembers().size() < 6) {
/* 725 */                         partyService.updateParty(party.getPartyId(), PartyOperation.加入队伍, expelled);
/* 726 */                         chr.receivePartyMemberHP();
/* 727 */                         chr.updatePartyMemberHP();
/* 728 */                         chr.send(PartyPacket.expeditionStatus(exped, true));
                       }
                     } else {
/* 731 */                       MapleParty party = partyService.createPartyAndAdd(expelled, exped.getId());
/* 732 */                       chr.setParty(party);
/* 733 */                       chr.send(PartyPacket.partyCreated(party));
/* 734 */                       chr.send(PartyPacket.expeditionStatus(exped, true));
/* 735 */                       partyService.sendExpedPacket(exped.getId(), PartyPacket.expeditionUpdate(exped.getIndex(party.getPartyId()), party), null);
                     }
/* 737 */                     if (player.getEventInstance() != null && 
/* 738 */                       expelled.isOnline()) {
/* 739 */                       player.getEventInstance().disbandParty();
                     }

/* 742 */                     if (player.getPyramidSubway() != null) {
/* 743 */                       player.getPyramidSubway().fail(c.getPlayer());
                     }
                     break;
                   }
                 }  }

             }
           }
         }
         return;
     }
/* 754 */     if (ServerConstants.isShowPacket())
/* 755 */       System.out.println("未知的远征队操作 : 0x" + StringUtil.getLeftPaddedStr(Integer.toHexString(mode).toUpperCase(), '0', 2) + " " + slea); 
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\channel\handler\PartyHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */